Digital-logic system components are often implemented together on a single chip (i.e., system on a chip or SOC). On-chip buses connect different components which often compete for resources. One approach to improve the efficiency of a SOC system involves out-of-order execution of commands received by a shared resource. For example, a memory may be shared by two on-chip processors, where one processor is faster than the other. A long series of commands between the memory and the slow processor may delay a later-received command of the fast processor. With out-of-order command execution, the commands of the slow processor may be temporarily suspended so that the command of the fast processor may be executed. The increase in the total execution time for the series of commands of the slow processor may be negligible, while the command of the fast processor avoids a potentially significant delay.
A re-order buffer (ROB) may be implemented for out-of-order execution of commands. FIG. 1 depicts an example diagram for a re-order buffer. As shown in FIG. 1, a re-order buffer 12 is configured to reorder data packets in a data sequence 14 obtained through out-of-order execution of a command sequence 16, and output a reordered data sequence 18.
Specifically, the command sequence 16 includes multiple read commands, e.g., CY0, CY1, CU0, CY2, . . . , etc., where “C” stands for “command,” “Y” and “U” represent two different streams, and the numerals “0,” “1” and “2” represent command identifications (IDs). A stream includes a series of commands from a same source, or a series of commands directed to a same target address or consecutive target addresses. In addition, the data sequence 14 and the data sequence 18 each include multiple data packets, e.g., DY1, DU0, DY0, DY3, . . . , etc., where “D” stands for “data,” and “Y” and “U” represent the two different streams.
Multiple commands for two streams (e.g., the streams “Y” and “U”) are interleaved in the command sequence 16. For example, the commands “CY0” and “CY1” for the stream “Y” precede the command “CU0” for another stream “U” which is followed by another command “CY2” for the stream “Y.” The data sequence 14 is obtained through out-of-order execution of the commands in the command sequence 16. The ROB 12 reorders the data packets in the data sequence 14 so that the data packets for a same stream are to be output in a specific order. For example, for the stream “Y,” the data packet “DY1” precedes the data packet “DY0” in the data sequence 14, and after the reordering of the ROB 12, the data packet “DY1” follows the data packet “DY0” in the data sequence 16. Similarly, for the stream “U,” the data packet “DU2” precedes the data packet “DU1” in the data sequence 14, and after the reordering of the ROB 12, the data packet “DU2” follows the data packet “DU1” in the data sequence 106. In addition, the ROB 12 reorders the data packets in the data sequence 14 so that the data packets for different streams can be output according to a priority parameter.
Out-of-order execution may cause certain hazards which need to be resolved in a SOC system. For example, a write command and a read command are consecutively sent to a same target address. If the write command and the read command are executed out of order, the updated data at the target address may not be read back as planned. In this case, the execution order of the write command and the read command has to be maintained so that updated data at the target address can be returned. In another example, two write commands are consecutively sent to a same target address, and usually have to be executed in order to ensure that the latest data is written last.
FIG. 2 depicts an example diagram for a hazard controller. As shown in FIG. 2, the hazard controller 22 is configured to keep the execution order of certain commands in a command sequence 24 during the out-of-order execution of commands. Specifically, the command sequence 24 includes a write command “W0” and a read command “R2” that are both directed to a same target address “0×100.” Though the read command “R2” has a higher priority parameter (e.g., P=5) than the write command “W0” (e.g., P=1), the write command “W0” has to be executed before the read command “R2” so that the updated data at the target address “0×100” can be read back. In addition, the command sequence 24 includes two write commands “W1” and “W3” that are both directed to a same target address “0×80.” Though the write command “W3” has a higher priority parameter (e.g., P=9) than the write command “W1” (e.g., P=3), the write command “W3” is executed after the write command “W1.” As such, the hazard controller 22 maintains the execution order of these commands in a command sequence 26 that is generated by reordering the commands based at least in part on the priority parameter.